package com.JohnCarloSalter.BackEnd;

public class CMD_DisplayTab implements CommandInterface {
	private Aggregator aggregator;
	
	public CMD_DisplayTab (Aggregator a) {
		aggregator = a;
	}
	
	//Method to create the tab.
	private Tab getTab() {
		Orders o = aggregator.getOrders();
		String[] stringList = new String[o.getNumberOfOrders()];
		double totalPrice = 0;
		Item temp;
		
		for(int i=0; i<stringList.length; i++) {
			temp = aggregator.getMenu().getItem(o.getOrder(i));
			stringList[i] = temp.toString();
			totalPrice += temp.getPrice();
		}
		
		return new Tab(stringList, totalPrice);		
	}

	public String execute() {
		return getTab().toString();
	}
}
